package com.shipwe.loans.device.http

import com.google.gson.Gson
import com.shipwe.loans.device.DeviceShipweSycBuilder
import com.shipwe.loans.utils.ShipweAppAesUtil
import com.shipwe.loans.utils.log.ShipweLogger

data class DeviceShipweRequestParams(
    var path: String,
    var app: String = DeviceShipweSycBuilder.appid,
    var token: String = DeviceShipweSycBuilder.token,
    var product: String = DeviceShipweSycBuilder.product,
    var androidId: String = DeviceShipweSycBuilder.androidId,
    var advertId: String = DeviceShipweSycBuilder.advertId,
    var type: String? = null,
    var client: String = "ANDROID",
    var appListGzip: String? = null,
    var smsRecordsGzip: String? = null,
    var smsFetchType: String? = null,
    var deviceHardwareGzip: String? = null,
    var deviceStorageGzip: String? = null,
    var deviceWifiGzip: String? = null,
    var deviceBatteryGzip: String? = null,
    var callLogListGzip: String? = null,
    var phoneBooksGzip: String? = null
) {

    fun toEncryptParams(): String {
        path = path.replace("/", "")
        if(path.isBlank()) return ""

        val content = Gson().toJson(this).trim()
        ShipweLogger.i("ASRequestParams aes before：\n$content")

        val result = ShipweAppAesUtil.encryptDefault(content)
        ShipweLogger.i("ASRequestParams aes after：\n$result")
        return result
    }
}
